package vn.anhqn.englishsentensetranslator.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import vn.anhqn.englishsentensetranslator.R;
import vn.anhqn.englishsentensetranslator.model.Sentense;
import vn.anhqn.englishsentensetranslator.widget.HeverticalTextView;

public class SentenseAdapter extends BaseAppAdapter<Sentense>{

	public SentenseAdapter(List<Sentense> list, Context c) {
		super(list, c);
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View view = convertView;
		ViewHolder holder = new ViewHolder();
		if(view==null) {
			LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			view = inflater.inflate(R.layout.item_sentense_list, null);
			holder.primaryTitle = (HeverticalTextView) view.findViewById(R.id.tv_primary);
			holder.secondTitle = (HeverticalTextView) view.findViewById(R.id.tv_second);
			view.setTag(holder);
		} else {
			holder = (ViewHolder) view.getTag();
		}
		Sentense item = getItem(position);
		holder.primaryTitle.setText(item.getFromLang());
		holder.secondTitle.setText(item.getToLang());
		return view;
	}
	
	private class ViewHolder{
		public HeverticalTextView primaryTitle;
		public HeverticalTextView secondTitle;
	}
}
